package com.sun.service.subject;

import com.sun.model.entity.Options;
import com.sun.model.entity.Subject;
import com.sun.model.example.SubjectExample;
import com.sun.model.mapper.SubjectMapper;
import com.sun.service.options.OptionsService;
import com.until.server.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * @author AdminUser
 */
@Service
public class SubjectInfoService extends BaseService<Subject, SubjectExample,String> implements SubjectMapper,SubjectInfoServerMapper {
    @Autowired
    private SubjectMapper subjectMapper;

    @Autowired
    private OptionsService optionsService;

    @Override
    public long countByExample(SubjectExample example) {
        return 0;
    }

    @Override
    public int deleteByExample(SubjectExample example) {
        return 0;
    }

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return 0;
    }

    @Override
    public int insert(Subject record) {
        return 0;
    }

    @Override
    public int insertSelective(Subject record) {
        return subjectMapper.insertSelective(record);
    }

    @Override
    public List<Subject> selectByExample(SubjectExample example) {
        return subjectMapper.selectByExample(example);
    }

    @Override
    public Subject selectByPrimaryKey(Integer id) {
        return null;
    }

    @Override
    public int updateByExampleSelective(Subject record, SubjectExample example) {
        return 0;
    }

    @Override
    public int updateByExample(Subject record, SubjectExample example) {
        return 0;
    }

    @Override
    public int updateByPrimaryKeySelective(Subject record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(Subject record) {
        return 0;
    }

    @Override
    public List<Subject> coreSelection(Subject model, String action, HttpMethod method) throws Exception {
        return selectByExample(this.getExtension(model, action,method));
    }

    @Override
    public List<Subject> getAllList() {
        return subjectMapper.getAllList();
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public int insertObject(Subject subject, List<Options> options) {
        this.insertSelective(subject);
//        for (Options option:options) {
//            option.setVsid(subject.getId());
//            optionsService.insertSelective(option);
//        }
        return 1;
    }
}
